package com.wholesale.datas;

import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.InetSocketAddress;
import java.net.URL;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.SoapFault;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.AndroidHttpTransport;
import org.ksoap2.transport.HttpTransportSE;
import org.xmlpull.v1.XmlPullParserException;

import android.graphics.Bitmap;
import android.util.Log;

import com.wholesale.beans.BoughtGoods;
import com.wholesale.beans.CartInfo;
import com.wholesale.beans.CatInfo;
import com.wholesale.beans.CollectGoods;
import com.wholesale.beans.Comment;
import com.wholesale.beans.Country;
import com.wholesale.beans.Feedback;
import com.wholesale.beans.GoodsCategory;
import com.wholesale.beans.GoodsDetail;
import com.wholesale.beans.GoodsGallery;
import com.wholesale.beans.GoodsInfo;
import com.wholesale.beans.GoodsType;
import com.wholesale.beans.LoginRequest;
import com.wholesale.beans.LoginResponse;
import com.wholesale.beans.Order;
import com.wholesale.beans.OrderDetail;
import com.wholesale.beans.OrderTrackingInfo;
import com.wholesale.beans.PaymentMethod;
import com.wholesale.beans.ShippingArea;
import com.wholesale.beans.ShippingMethod;
import com.wholesale.beans.UploadOrderResponse;
import com.wholesale.beans.UserAddress;
import com.wholesale.beans.UserInfo;
import com.wholesale.beans.WhoAttribute;
import com.wholesale.beans.WhoGoodsAttr;
import com.wholesale.commons.LogUtil;
import com.wholesale.utils.Constants;

public class WebServiceClient {
	private final static String WEB_SERVICE_URL = "http://174.121.139.2:7777/ServiceApp/WholesaleWS";
	// private final static String WEB_SERVICE_URL =
	// "http://174.122.69.130:7777/ServiceApp/WholesaleWS";
	// private final static String WEB_SERVICE_URL =
	// "http://192.168.1.101:8080/ServiceApp/WholesaleWS";
	private final static String WEB_SEVICE_NAMESPACE = "http://webservice.wholesale.com/";

	public static HttpTransportSE getHttpTransportSE(String url) {
		HttpTransportSE ht = null;
		String proxyHost = android.net.Proxy.getDefaultHost();
		if (proxyHost != null) {
			java.net.Proxy p = new java.net.Proxy(java.net.Proxy.Type.HTTP,
					new InetSocketAddress(android.net.Proxy.getDefaultHost(),
							android.net.Proxy.getDefaultPort()));
			// ht=new HttpTransportSE(p,url);
		} else {
			ht = new HttpTransportSE(url);
		}
		return ht;
	}

	public static Bitmap getBitmap(String url) {

		return null;
	}

	/**
	 * 注册新用户
	 * 
	 * @param email
	 * @param password
	 * @return 0.success 1.userName&Email is existed 2.error
	 */
	public static String registerNewUser(String email, String password) {
		SoapObject request = new SoapObject(WEB_SEVICE_NAMESPACE,
				"registerNewUser");
		request.addProperty("userName", email);
		request.addProperty("password", password);
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		envelope.setOutputSoapObject(request);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(
				WEB_SERVICE_URL);
		String result = "2";
		try {
			androidHttpTransport.call(null, envelope);
			Object object = envelope.getResponse();
			result = object.toString();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (XmlPullParserException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return result;
	}

	/**
	 * 
	 * 登录
	 * 
	 * @参数： loginRequestObjStr - loginRequest对象对应的json字符串
	 * @返回: LoginResponse对象json字符串
	 */
	public static LoginResponse login(String loginRequestObjStr) {
		LoginResponse loginResponse = null;
		SoapObject request = new SoapObject(WEB_SEVICE_NAMESPACE, "login");
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(
				WEB_SERVICE_URL);
		request.addProperty("loginRequestObjStr", loginRequestObjStr);
		// request.setProperty(0, loginObject);
		envelope.setOutputSoapObject(request);
		try {
			androidHttpTransport.call(null, envelope);
			Object object = envelope.getResponse();
			loginResponse = new LoginResponse();
			loginResponse.jsonAnalytic(object.toString());
		} catch (SoapFault e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"login ; " + e.getMessage());
		} catch (IOException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"login ; " + e.getMessage());
		} catch (XmlPullParserException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"login ; " + e.getMessage());
		}
		return loginResponse;
	}

	/**
	 * 登出操作
	 * 
	 * @param LogoutRequestObjStr
	 * @return boolean true 退出成功，false退出失败
	 */
	public static boolean logout(String LogoutRequestObjStr) {
		Boolean result = false;
		SoapObject request = new SoapObject(WEB_SEVICE_NAMESPACE, "logout");
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(
				WEB_SERVICE_URL);
		request.addProperty("LogoutRequestObjStr", LogoutRequestObjStr);
		// request.setProperty(0, loginObject);
		envelope.setOutputSoapObject(request);
		try {
			androidHttpTransport.call("logout", envelope);
			Object object = envelope.getResponse();
			result = Boolean.parseBoolean(object.toString());
		} catch (SoapFault e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"logout ; " + e.getMessage());
		} catch (IOException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"logout ; " + e.getMessage());
		} catch (XmlPullParserException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"logout ; " + e.getMessage());
		}
		return result;
	}

	/**
	 * 
	 * @param email
	 * @param password
	 * @return 0.success 1.userName&Email is existed 2.error
	 */
	public static LoginResponse login(String email, String password) {
		LoginRequest loginRequest = new LoginRequest();
		loginRequest.setUserId(email);
		loginRequest.setPassword(password);
		UUID uuid = UUID.randomUUID();
		loginRequest.setRequestId(uuid.toString());
		return login(loginRequest.toJsonString());
	}

	/**
	 * 
	 * 获取最熱商品列表分页总数
	 * 
	 * @return long
	 */
	public static Long getHotGoodsListPageCount() {
		SoapObject request = new SoapObject(WEB_SEVICE_NAMESPACE,
				"getHotGoodsListPageCount");
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(
				WEB_SERVICE_URL);
		// request.setProperty(0, loginObject);
		envelope.setOutputSoapObject(request);
		try {
			androidHttpTransport.call("getHotGoodsListPageCount", envelope);
			Object object = envelope.getResponse();
			if (object != null) {
				return Long.parseLong(object.toString());
			}
		} catch (SoapFault e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getHotGoodsListPageCount ; " + e.getMessage());
		} catch (IOException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getHotGoodsListPageCount ; " + e.getMessage());
		} catch (XmlPullParserException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getHotGoodsListPageCount ; " + e.getMessage());
		}
		return 0L;
	}

	/**
	 * 获取最热商品列表
	 * 
	 * @param pageNum
	 *            页数
	 * @param shortBy
	 *            排序字段
	 * @param desc
	 *            升序
	 * @return ArrayList<GoodsInfo>
	 */
	public static ArrayList<GoodsInfo> getHotGoodsList(int pageNum,
			java.lang.String shortBy, boolean desc) {
		ArrayList<GoodsInfo> list = new ArrayList<GoodsInfo>();
		SoapObject request = new SoapObject(WEB_SEVICE_NAMESPACE,
				"getHotGoodsList");
		request.addProperty("pageNum", pageNum);
		request.addProperty("shortBy", shortBy);
		request.addProperty("desc", desc);
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(
				WEB_SERVICE_URL);
		envelope.setOutputSoapObject(request);
		try {
			androidHttpTransport.call("getHotGoodsList", envelope);
			Object object = envelope.getResponse();
			JSONArray arr = new JSONArray(object.toString());
			int size = arr.length();
			for (int i = 0; i < size; i++) {
				GoodsInfo oodsInfo = new GoodsInfo();
				oodsInfo.jsonAnalytic(arr.getJSONObject(i));
				list.add(oodsInfo);
			}
		} catch (SoapFault e) {
			LogUtil.e(WebServiceClient.class.getName(), "getHotGoodsList ; "
					+ e.getMessage());
		} catch (IOException e) {
			LogUtil.e(WebServiceClient.class.getName(), "getHotGoodsList ; "
					+ e.getMessage());
		} catch (XmlPullParserException e) {
			LogUtil.e(WebServiceClient.class.getName(), "getHotGoodsList ; "
					+ e.getMessage());
		} catch (JSONException e) {
			LogUtil.e(WebServiceClient.class.getName(), "getHotGoodsList ; "
					+ e.getMessage());
		}
		return list;
	}

	/**
	 * 
	 * 获取所有的商品类型信息
	 * 
	 * @return ArrayList<GoodsType>
	 */
	public static ArrayList<GoodsType> getGoodsTypes() {
		ArrayList<GoodsType> list = new ArrayList<GoodsType>();
		SoapObject request = new SoapObject(WEB_SEVICE_NAMESPACE,
				"getGoodsTypes");
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(
				WEB_SERVICE_URL);
		// request.setProperty(0, loginObject);
		envelope.setOutputSoapObject(request);
		try {
			androidHttpTransport.call("getGoodsTypes", envelope);
			Object object = envelope.getResponse();
			JSONArray arr = new JSONArray(object.toString());
			int size = arr.length();
			for (int i = 0; i < size; i++) {
				GoodsType goodsType = new GoodsType();
				goodsType.jsonAnalytic(arr.getJSONObject(i));
				list.add(goodsType);
			}
		} catch (SoapFault e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getGoodsTypes ; " + e.getMessage());
		} catch (IOException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getGoodsTypes ; " + e.getMessage());
		} catch (XmlPullParserException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getGoodsTypes ; " + e.getMessage());
		} catch (JSONException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getGoodsTypes ; " + e.getMessage());
		}
		return list;
	}

	/**
	 * 
	 * 获取最新商品列表分页总数
	 * 
	 * @return long
	 */
	public static Long getNewGoodsListPageCount() {
		SoapObject request = new SoapObject(WEB_SEVICE_NAMESPACE,
				"getNewGoodsListPageCount");
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(
				WEB_SERVICE_URL);
		envelope.setOutputSoapObject(request);
		try {
			androidHttpTransport.call("getNewGoodsListPageCount", envelope);
			Object object = envelope.getResponse();
			if (object != null) {
				return Long.parseLong(object.toString());
			}
		} catch (SoapFault e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getNewGoodsListPageCount ; " + e.getMessage());
		} catch (IOException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getNewGoodsListPageCount ; " + e.getMessage());
		} catch (XmlPullParserException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getNewGoodsListPageCount ; " + e.getMessage());
		}
		return 0L;
	}

	/**
	 * 获取最新商品列表
	 * 
	 * @param pageNum
	 *            页数
	 * @param shortBy
	 *            排序字段
	 * @param desc
	 *            升序
	 * @return ArrayList<GoodsInfo>
	 */
	public static ArrayList<GoodsInfo> getNewGoodsList(int pageNum,
			java.lang.String shortBy, boolean desc) {
		ArrayList<GoodsInfo> list = new ArrayList<GoodsInfo>();
		SoapObject request = new SoapObject(WEB_SEVICE_NAMESPACE,
				"getNewGoodsList");
		request.addProperty("pageNum", pageNum);
		request.addProperty("shortBy", shortBy);
		request.addProperty("desc", desc);
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(
				WEB_SERVICE_URL);
		envelope.setOutputSoapObject(request);
		try {
			androidHttpTransport.call("getNewGoodsList", envelope);
			Object object = envelope.getResponse();
			JSONArray arr = new JSONArray(object.toString());
			int size = arr.length();
			for (int i = 0; i < size; i++) {
				GoodsInfo oodsInfo = new GoodsInfo();
				oodsInfo.jsonAnalytic(arr.getJSONObject(i));
				list.add(oodsInfo);
			}
		} catch (SoapFault e) {
			LogUtil.e(WebServiceClient.class.getName(), "getNewGoodsList ; "
					+ e.getMessage());
		} catch (IOException e) {
			LogUtil.e(WebServiceClient.class.getName(), "getNewGoodsList ; "
					+ e.getMessage());
		} catch (XmlPullParserException e) {
			LogUtil.e(WebServiceClient.class.getName(), "getNewGoodsList ; "
					+ e.getMessage());
		} catch (JSONException e) {
			LogUtil.e(WebServiceClient.class.getName(), "getNewGoodsList ; "
					+ e.getMessage());
		}
		return list;
	}

	/**
	 * 
	 * 获取under3商品总页数
	 * 
	 * @return long
	 */
	public static Long getUnder3GoodsPageCount() {
		SoapObject request = new SoapObject(WEB_SEVICE_NAMESPACE,
				"getUnder3GoodsPageCount");
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(
				WEB_SERVICE_URL);
		envelope.setOutputSoapObject(request);
		try {
			androidHttpTransport.call("getUnder3GoodsPageCount", envelope);
			Object object = envelope.getResponse();
			if (object != null) {
				return Long.parseLong(object.toString());
			}
		} catch (SoapFault e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getUnder3GoodsPageCount ; " + e.getMessage());
		} catch (IOException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getUnder3GoodsPageCount ; " + e.getMessage());
		} catch (XmlPullParserException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getUnder3GoodsPageCount ; " + e.getMessage());
		}
		return 0L;
	}

	/**
	 * 获取under 3商品信息列表
	 * 
	 * @param pageNum
	 *            页码
	 * @param shortBy
	 *            排序信息
	 * @param desc
	 *            是否降序
	 * @return ArrayList<GoodsInfo>
	 */
	public static ArrayList<GoodsInfo> getUnder3Goods(int pageNum,
			java.lang.String shortBy, boolean desc) {
		ArrayList<GoodsInfo> list = new ArrayList<GoodsInfo>();
		SoapObject request = new SoapObject(WEB_SEVICE_NAMESPACE,
				"getUnder3Goods");
		request.addProperty("pageNum", pageNum);
		request.addProperty("shortBy", shortBy);
		request.addProperty("desc", desc);
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(
				WEB_SERVICE_URL);
		envelope.setOutputSoapObject(request);
		try {
			androidHttpTransport.call("getUnder3Goods", envelope);
			Object object = envelope.getResponse();
			JSONArray arr = new JSONArray(object.toString());
			int size = arr.length();
			for (int i = 0; i < size; i++) {
				GoodsInfo oodsInfo = new GoodsInfo();
				oodsInfo.jsonAnalytic(arr.getJSONObject(i));
				list.add(oodsInfo);
			}
		} catch (SoapFault e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getUnder3Goods ; " + e.getMessage());
		} catch (IOException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getUnder3Goods ; " + e.getMessage());
		} catch (XmlPullParserException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getUnder3Goods ; " + e.getMessage());
		} catch (JSONException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getUnder3Goods ; " + e.getMessage());
		}
		return list;
	}

	/**
	 * 获取商品一级分类信息
	 * 
	 * @return List<GoodsCategory>
	 */
	public static ArrayList<GoodsCategory> getCategoryLevel1() {
		ArrayList<GoodsCategory> list = new ArrayList<GoodsCategory>();
		SoapObject request = new SoapObject(WEB_SEVICE_NAMESPACE,
				"getCategoryLevel1");
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(
				WEB_SERVICE_URL);
		envelope.setOutputSoapObject(request);
		try {
			androidHttpTransport.call("getCategoryLevel1", envelope);
			Object object = envelope.getResponse();
			JSONArray arr = new JSONArray(object.toString());
			int size = arr.length();
			for (int i = 0; i < size; i++) {
				GoodsCategory goodsCategory = new GoodsCategory();
				goodsCategory.jsonAnalytic(arr.getJSONObject(i));
				list.add(goodsCategory);
			}
		} catch (SoapFault e) {
			LogUtil.e(WebServiceClient.class.getName(), "getCategoryLevel1 ; "
					+ e.getMessage());
		} catch (IOException e) {
			LogUtil.e(WebServiceClient.class.getName(), "getCategoryLevel1 ; "
					+ e.getMessage());
		} catch (XmlPullParserException e) {
			LogUtil.e(WebServiceClient.class.getName(), "getCategoryLevel1 ; "
					+ e.getMessage());
		} catch (JSONException e) {
			LogUtil.e(WebServiceClient.class.getName(), "getCategoryLevel1 ; "
					+ e.getMessage());
		}
		return list;
	}

	/**
	 * 获取二级分类信息
	 * 
	 * @return
	 */
	public static ArrayList<GoodsCategory> getCategoryLevel2(int parentCatId) {
		ArrayList<GoodsCategory> list = new ArrayList<GoodsCategory>();
		SoapObject request = new SoapObject(WEB_SEVICE_NAMESPACE,
				"getCategoryLevel2");
		request.addProperty("parentCatId", parentCatId);
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(
				WEB_SERVICE_URL);
		envelope.setOutputSoapObject(request);
		try {
			androidHttpTransport.call("getCategoryLevel2", envelope);
			Object object = envelope.getResponse();
			JSONArray arr = new JSONArray(object.toString());
			int size = arr.length();
			for (int i = 0; i < size; i++) {
				GoodsCategory goodsCategory = new GoodsCategory();
				goodsCategory.jsonAnalytic(arr.getJSONObject(i));
				list.add(goodsCategory);
			}
		} catch (SoapFault e) {
			LogUtil.e(WebServiceClient.class.getName(), "getCategoryLevel2 ; "
					+ e.getMessage());
		} catch (IOException e) {
			LogUtil.e(WebServiceClient.class.getName(), "getCategoryLevel2 ; "
					+ e.getMessage());
		} catch (XmlPullParserException e) {
			LogUtil.e(WebServiceClient.class.getName(), "getCategoryLevel2 ; "
					+ e.getMessage());
		} catch (JSONException e) {
			LogUtil.e(WebServiceClient.class.getName(), "getCategoryLevel2 ; "
					+ e.getMessage());
		}
		return list;
	}

	/**
	 * 获取产品信息列表总页数，通过分类
	 * 
	 * @param catId
	 *            分类Id
	 * @return
	 */
	public static Long getGoodsListByCatPageCount(int catId) {
		SoapObject request = new SoapObject(WEB_SEVICE_NAMESPACE,
				"getGoodsListByCatPageCount");
		request.addProperty("catId", catId);
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(
				WEB_SERVICE_URL);
		envelope.setOutputSoapObject(request);
		try {
			androidHttpTransport.call("getGoodsListByCatPageCount", envelope);
			Object object = envelope.getResponse();
			if (object != null) {
				return Long.parseLong(object.toString());
			}
		} catch (SoapFault e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getGoodsListByCatPageCount ; " + e.getMessage());
		} catch (IOException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getGoodsListByCatPageCount ; " + e.getMessage());
		} catch (XmlPullParserException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getGoodsListByCatPageCount ; " + e.getMessage());
		}
		return 0L;
	}

	/**
	 * 获取产品信息列表，通过分类
	 * 
	 * @param catId
	 *            分类ID
	 * @param pageNum
	 *            页码
	 * @param shortBy
	 *            排序信息 “是需要进行排序的数据库字段名称字符串” "shopPrice" "lastUpdate" 下同
	 * @param desc
	 *            是否降序
	 * @return ArrayList<GoodsInfo>
	 */
	public static ArrayList<GoodsInfo> getGoodsListByCat(int catId,
			int pageNum, java.lang.String shortBy, boolean desc) {
		ArrayList<GoodsInfo> list = new ArrayList<GoodsInfo>();
		SoapObject request = new SoapObject(WEB_SEVICE_NAMESPACE,
				"getGoodsListByCat");
		request.addProperty("catId", catId);
		request.addProperty("pageNum", pageNum);
		request.addProperty("shortBy", shortBy);
		request.addProperty("desc", desc);
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(
				WEB_SERVICE_URL);
		envelope.setOutputSoapObject(request);
		try {
			androidHttpTransport.call("getGoodsListByCat", envelope);
			Object object = envelope.getResponse();
			JSONArray arr = new JSONArray(object.toString());
			int size = arr.length();
			for (int i = 0; i < size; i++) {
				GoodsInfo oodsInfo = new GoodsInfo();
				oodsInfo.jsonAnalytic(arr.getJSONObject(i));
				list.add(oodsInfo);
			}
		} catch (SoapFault e) {
			LogUtil.e(WebServiceClient.class.getName(), "getGoodsListByCat ; "
					+ e.getMessage());
		} catch (IOException e) {
			LogUtil.e(WebServiceClient.class.getName(), "getGoodsListByCat ; "
					+ e.getMessage());
		} catch (XmlPullParserException e) {
			LogUtil.e(WebServiceClient.class.getName(), "getGoodsListByCat ; "
					+ e.getMessage());
		} catch (JSONException e) {
			LogUtil.e(WebServiceClient.class.getName(), "getGoodsListByCat ; "
					+ e.getMessage());
		}
		return list;
	}

	/**
	 * 获取所有可用的支付方式
	 * 
	 * @return
	 */
	public static ArrayList<PaymentMethod> getPaymentMethods() {
		ArrayList<PaymentMethod> list = new ArrayList<PaymentMethod>();
		SoapObject request = new SoapObject(WEB_SEVICE_NAMESPACE,
				"getPaymentMethods");
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(
				WEB_SERVICE_URL);
		envelope.setOutputSoapObject(request);
		try {
			androidHttpTransport.call("getPaymentMethods", envelope);
			Object object = envelope.getResponse();
			JSONArray arr = new JSONArray(object.toString());
			int size = arr.length();
			for (int i = 0; i < size; i++) {
				PaymentMethod paymentMethod = new PaymentMethod();
				paymentMethod.jsonAnalytic(arr.getJSONObject(i));
				list.add(paymentMethod);
			}
		} catch (SoapFault e) {
			LogUtil.e(WebServiceClient.class.getName(), "getPaymentMethods ; "
					+ e.getMessage());
		} catch (IOException e) {
			LogUtil.e(WebServiceClient.class.getName(), "getPaymentMethods ; "
					+ e.getMessage());
		} catch (XmlPullParserException e) {
			LogUtil.e(WebServiceClient.class.getName(), "getPaymentMethods ; "
					+ e.getMessage());
		} catch (JSONException e) {
			LogUtil.e(WebServiceClient.class.getName(), "getPaymentMethods ; "
					+ e.getMessage());
		}
		return list;
	}

	/**
	 * 获取所有的配送方案
	 * 
	 * @return List<ShippingMethod>
	 */
	public static ArrayList<ShippingMethod> getShippingMethods() {
		ArrayList<ShippingMethod> list = new ArrayList<ShippingMethod>();
		SoapObject request = new SoapObject(WEB_SEVICE_NAMESPACE,
				"getShippingMethods");
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(
				WEB_SERVICE_URL);
		envelope.setOutputSoapObject(request);
		try {
			androidHttpTransport.call("getShippingMethods", envelope);
			Object object = envelope.getResponse();
			JSONArray arr = new JSONArray(object.toString());
			int size = arr.length();
			for (int i = 0; i < size; i++) {
				ShippingMethod shippingMethod = new ShippingMethod();
				shippingMethod.jsonAnalytic(arr.getJSONObject(i));
				list.add(shippingMethod);
			}
		} catch (SoapFault e) {
			LogUtil.e(WebServiceClient.class.getName(), "getShippingMethods ; "
					+ e.getMessage());
		} catch (IOException e) {
			LogUtil.e(WebServiceClient.class.getName(), "getShippingMethods ; "
					+ e.getMessage());
		} catch (XmlPullParserException e) {
			LogUtil.e(WebServiceClient.class.getName(), "getShippingMethods ; "
					+ e.getMessage());
		} catch (JSONException e) {
			LogUtil.e(WebServiceClient.class.getName(), "getShippingMethods ; "
					+ e.getMessage());
		}
		return list;
	}

	/**
	 * 通过who_user_address表中的address_id字段来获取所有匹配这个地址的配送方式
	 * 
	 * @param addressId
	 *            who_user_address表中的address_id
	 * @return List<ShippingMethod>
	 */
	public static ArrayList<ShippingMethod> getShippingInfoByAddress(
			int addressId, ArrayList<BoughtGoods> boughtGoodsList) {
		ArrayList<ShippingMethod> list = new ArrayList<ShippingMethod>();
		SoapObject request = new SoapObject(WEB_SEVICE_NAMESPACE,
				"getShippingInfoByAddress");
		request.addProperty("addressId", addressId);
		JSONArray jsonArray = new JSONArray();
		for (BoughtGoods boughtGoods : boughtGoodsList) {
			jsonArray.put(boughtGoods.getJSONObject());
		}
		request.addProperty("boughtGoodsList", jsonArray.toString());
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(
				WEB_SERVICE_URL);
		envelope.setOutputSoapObject(request);
		try {
			androidHttpTransport.call(null, envelope);
			Object object = envelope.getResponse();
			JSONArray arr = new JSONArray(object.toString());
			int size = arr.length();
			for (int i = 0; i < size; i++) {
				ShippingMethod shippingMethod = new ShippingMethod();
				shippingMethod.jsonAnalytic(arr.getJSONObject(i));
				list.add(shippingMethod);
			}
		} catch (SoapFault e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getShippingInfoByAddress ; " + e.getMessage());
		} catch (IOException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getShippingInfoByAddress ; " + e.getMessage());
		} catch (XmlPullParserException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getShippingInfoByAddress ; " + e.getMessage());
		} catch (JSONException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getShippingInfoByAddress ; " + e.getMessage());
		}
		return list;
	}

	/**
	 * 获取指定配送方案对应的区域信息
	 * 
	 * @return List<ShippingArea>
	 */
	public static List<ShippingArea> getShippingArea(int shippingId) {
		ArrayList<ShippingArea> list = new ArrayList<ShippingArea>();
		SoapObject request = new SoapObject(WEB_SEVICE_NAMESPACE,
				"getShippingArea");
		request.addProperty("shippingId", shippingId);
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(
				WEB_SERVICE_URL);
		envelope.setOutputSoapObject(request);
		try {
			androidHttpTransport.call("getShippingArea", envelope);
			Object object = envelope.getResponse();
			JSONArray arr = new JSONArray(object.toString());
			int size = arr.length();
			for (int i = 0; i < size; i++) {
				ShippingArea shippingArea = new ShippingArea();
				shippingArea.jsonAnalytic(arr.getJSONObject(i));
				list.add(shippingArea);
			}
		} catch (SoapFault e) {
			LogUtil.e(WebServiceClient.class.getName(), "getShippingArea ; "
					+ e.getMessage());
		} catch (IOException e) {
			LogUtil.e(WebServiceClient.class.getName(), "getShippingArea ; "
					+ e.getMessage());
		} catch (XmlPullParserException e) {
			LogUtil.e(WebServiceClient.class.getName(), "getShippingArea ; "
					+ e.getMessage());
		} catch (JSONException e) {
			LogUtil.e(WebServiceClient.class.getName(), "getShippingArea ; "
					+ e.getMessage());
		}
		return list;
	}

	public static ArrayList<OrderDetail> getOrderDetail(int orderId,
			int userId, java.lang.String userToken) {
		ArrayList<OrderDetail> list = new ArrayList<OrderDetail>();
		SoapObject request = new SoapObject(WEB_SEVICE_NAMESPACE,
				"getOrderDetail");
		request.addProperty("orderId", orderId);
		request.addProperty("userId", userId);
		request.addProperty("userToken", userToken);
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(
				WEB_SERVICE_URL);
		envelope.setOutputSoapObject(request);
		try {
			androidHttpTransport.call(null, envelope);
			Object object = envelope.getResponse();
			JSONArray arr = new JSONArray(object.toString());
			int size = arr.length();
			for (int i = 0; i < size; i++) {
				OrderDetail orderDetail = new OrderDetail();
				orderDetail.jsonAnalytic(arr.getJSONObject(i));
				list.add(orderDetail);
			}

		} catch (SoapFault e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getOrderDetail ; " + e.getMessage());
		} catch (IOException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getOrderDetail ; " + e.getMessage());
		} catch (XmlPullParserException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getOrderDetail ; " + e.getMessage());
		} catch (JSONException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getOrderDetail ; " + e.getMessage());
		}
		return list;
	}

	/**
	 * 获取所有的国家信息
	 * 
	 * @return List<Country>
	 */
	public static List<Country> getCountries() {
		ArrayList<Country> list = new ArrayList<Country>();
		SoapObject request = new SoapObject(WEB_SEVICE_NAMESPACE,
				"getCountries");
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(
				WEB_SERVICE_URL);
		envelope.setOutputSoapObject(request);
		try {
			androidHttpTransport.call("getCountries", envelope);
			Object object = envelope.getResponse();
			JSONArray arr = new JSONArray(object.toString());
			int size = arr.length();
			for (int i = 0; i < size; i++) {
				Country country = new Country();
				country.jsonAnalytic(arr.getJSONObject(i));
				list.add(country);
			}
		} catch (SoapFault e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getCountries ; " + e.getMessage());
		} catch (IOException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getCountries ; " + e.getMessage());
		} catch (XmlPullParserException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getCountries ; " + e.getMessage());
		} catch (JSONException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getCountries ; " + e.getMessage());
		}
		return list;
	}

	/**
	 * 获取指定子region对象列表
	 * 
	 * @param parentId
	 *            上一级region的id
	 * @param regionLevel
	 *            等级 1.province 2.city 3.district
	 * @return
	 */
	public static List<Country> getRegionByParentParentId(int parentId,
			int regionLevel) {
		ArrayList<Country> list = new ArrayList<Country>();
		SoapObject request = new SoapObject(WEB_SEVICE_NAMESPACE,
				"getRegionByParentParentId");
		request.addProperty("parentId", parentId);
		request.addProperty("regionLevel", regionLevel);
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(
				WEB_SERVICE_URL);
		envelope.setOutputSoapObject(request);
		try {
			androidHttpTransport.call("getRegionByParentParentId", envelope);
			Object object = envelope.getResponse();
			JSONArray arr = new JSONArray(object.toString());
			int size = arr.length();
			for (int i = 0; i < size; i++) {
				Country country = new Country();
				country.jsonAnalytic(arr.getJSONObject(i));
				list.add(country);
			}
		} catch (SoapFault e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getRegionByParentParentId ; " + e.getMessage());
		} catch (IOException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getRegionByParentParentId ; " + e.getMessage());
		} catch (XmlPullParserException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getRegionByParentParentId ; " + e.getMessage());
		} catch (JSONException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getRegionByParentParentId ; " + e.getMessage());
		}
		return list;
	}

	/**
	 * 获取region的名字
	 * 
	 * @param regionId
	 * @return
	 */
	public static String getRegionName(int regionId) {
		String regionName = null;
		SoapObject request = new SoapObject(WEB_SEVICE_NAMESPACE,
				"getRegionName");
		request.addProperty("regionId", regionId);
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(
				WEB_SERVICE_URL);
		envelope.setOutputSoapObject(request);
		try {
			androidHttpTransport.call(null, envelope);
			Object object = envelope.getResponse();
			regionName = object.toString();
		} catch (SoapFault e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getRegionName ; " + e.getMessage());
		} catch (IOException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getRegionName ; " + e.getMessage());
		} catch (XmlPullParserException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getRegionName ; " + e.getMessage());
		}
		return regionName;
	}

	/**
	 * 获取用户资料
	 * 
	 * @param userId
	 *            用户登录后生成的Id
	 * @param userToken
	 *            用户登录后成功的Token
	 * @return UserInfo
	 */
	public static UserInfo getUserInfo(int userId, java.lang.String userToken) {
		UserInfo userInfo = null;
		SoapObject request = new SoapObject(WEB_SEVICE_NAMESPACE, "getUserInfo");
		request.addProperty("userId", userId);
		request.addProperty("userToken", userToken);
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(
				WEB_SERVICE_URL);
		envelope.setOutputSoapObject(request);
		try {
			androidHttpTransport.call("getUserInfo", envelope);
			Object object = envelope.getResponse();
			userInfo = new UserInfo();
			userInfo.jsonAnalytic(object.toString());
		} catch (SoapFault e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getRegionName ; " + e.getMessage());
		} catch (IOException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getRegionName ; " + e.getMessage());
		} catch (XmlPullParserException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getRegionName ; " + e.getMessage());
		}
		return userInfo;
	}

	/**
	 * 获取用户当前的余额 = 用户当前资金-冻结资金
	 * 
	 * @param userId
	 *            用户登录后生成的Id
	 * @param userToken
	 *            用户登录后成功的Token
	 * @return double
	 */
	public static double getUserBalance(int userId, java.lang.String userToken) {
		double result = 0;
		SoapObject request = new SoapObject(WEB_SEVICE_NAMESPACE,
				"getUserBalance");
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(
				WEB_SERVICE_URL);
		request.addProperty("userId", userId);
		request.addProperty("userToken", userToken);
		envelope.setOutputSoapObject(request);
		try {
			androidHttpTransport.call("getUserBalance", envelope);
			Object object = envelope.getResponse();
			result = Double.parseDouble(object.toString());
		} catch (SoapFault e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getUserBalance ; " + e.getMessage());
		} catch (IOException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getUserBalance ; " + e.getMessage());
		} catch (XmlPullParserException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getUserBalance ; " + e.getMessage());
		}
		return result;
	}

	/**
	 * 获取用户商品评价列表
	 * 
	 * @param userId
	 *            用户登录后生成的Id
	 * @param userToken
	 *            用户登录后成功的Token
	 * @return List<Comment>
	 */
	public static ArrayList<Comment> getUserComments(int userId,
			java.lang.String userToken) {
		ArrayList<Comment> list = new ArrayList<Comment>();
		SoapObject request = new SoapObject(WEB_SEVICE_NAMESPACE,
				"getUserComments");
		request.addProperty("userId", userId);
		request.addProperty("userToken", userToken);
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(
				WEB_SERVICE_URL);
		envelope.setOutputSoapObject(request);
		try {
			androidHttpTransport.call("getUserComments", envelope);
			Object object = envelope.getResponse();
			JSONArray arr = new JSONArray(object.toString());
			int size = arr.length();
			// 当parentsId 不等于0并且等于上一条评论的commentId时，突出显示效果
			int preCommentId = 0;
			for (int i = 0; i < size; i++) {
				Comment comment = new Comment();
				comment.jsonAnalytic(arr.getJSONObject(i));
				if (comment.getParentId() != 0
						&& comment.getParentId() == preCommentId) {
					comment.setReply(true);
				} else {
					preCommentId = comment.getCommentId();
				}
				list.add(comment);
			}
		} catch (SoapFault e) {
			LogUtil.e(WebServiceClient.class.getName(), "getUserComments ; "
					+ e.getMessage());
		} catch (IOException e) {
			LogUtil.e(WebServiceClient.class.getName(), "getUserComments ; "
					+ e.getMessage());
		} catch (XmlPullParserException e) {
			LogUtil.e(WebServiceClient.class.getName(), "getUserComments ; "
					+ e.getMessage());
		} catch (JSONException e) {
			LogUtil.e(WebServiceClient.class.getName(), "getUserComments ; "
					+ e.getMessage());
		}
		return list;
	}

	/**
	 * 获取用户的反馈信息
	 * 
	 * @param userId
	 *            用户登录后生成的Id
	 * @param userToken
	 *            用户登录后成功的Token
	 * @return List<Feedback>
	 */
	public static ArrayList<Feedback> getFeedback(int userId,
			java.lang.String userToken) {
		ArrayList<Feedback> list = new ArrayList<Feedback>();
		SoapObject request = new SoapObject(WEB_SEVICE_NAMESPACE, "getFeedback");
		request.addProperty("userId", userId);
		request.addProperty("userToken", userToken);
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(
				WEB_SERVICE_URL);
		envelope.setOutputSoapObject(request);
		try {
			androidHttpTransport.call("getFeedback", envelope);
			Object object = envelope.getResponse();
			JSONArray arr = new JSONArray(object.toString());
			int size = arr.length();
			for (int i = 0; i < size; i++) {
				Feedback feedback = new Feedback();
				feedback.jsonAnalytic(arr.getJSONObject(i));
				list.add(feedback);
			}
		} catch (SoapFault e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getFeedback ; " + e.getMessage());
		} catch (IOException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getFeedback ; " + e.getMessage());
		} catch (XmlPullParserException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getFeedback ; " + e.getMessage());
		} catch (JSONException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getFeedback ; " + e.getMessage());
		}
		return list;
	}

	/**
	 * 获取用户的购物车信息
	 * 
	 * @param userId
	 *            用户登录后生成的Id
	 * @param userToken
	 *            用户登录后成功的Token
	 * @return List<cartInfo>
	 */
	public static List<CartInfo> getCartInfo(int userId,
			java.lang.String userToken) {
		ArrayList<CartInfo> list = new ArrayList<CartInfo>();
		SoapObject request = new SoapObject(WEB_SEVICE_NAMESPACE, "getCartInfo");
		request.addProperty("userId", userId);
		request.addProperty("userToken", userToken);
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(
				WEB_SERVICE_URL);
		envelope.setOutputSoapObject(request);
		try {
			androidHttpTransport.call("getCartInfo", envelope);
			Object object = envelope.getResponse();
			JSONArray arr = new JSONArray(object.toString());
			int size = arr.length();
			for (int i = 0; i < size; i++) {
				CartInfo cartInfo = new CartInfo();
				cartInfo.jsonAnalytic(arr.getJSONObject(i));
				list.add(cartInfo);
			}
		} catch (SoapFault e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getCartInfo ; " + e.getMessage());
		} catch (IOException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getCartInfo ; " + e.getMessage());
		} catch (XmlPullParserException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getCartInfo ; " + e.getMessage());
		} catch (JSONException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getCartInfo ; " + e.getMessage());
		}
		return list;
	}

	/**
	 * 清空指定用户的购物车
	 * 
	 * @param userId
	 *            用户登录后生成的Id
	 * @param userToken
	 *            用户登录后成功的Token
	 * @return boolean true 清除成功，false清除失败
	 */
	public static boolean clearCart(int userId, java.lang.String userToken) {
		SoapObject request = new SoapObject(WEB_SEVICE_NAMESPACE, "clearCart");
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(
				WEB_SERVICE_URL);
		request.addProperty("userId", userId);
		request.addProperty("userToken", userToken);
		// request.setProperty(0, loginObject);
		envelope.setOutputSoapObject(request);
		try {
			androidHttpTransport.call("clearCart", envelope);
			Object object = envelope.getResponse();
			return Boolean.parseBoolean(object.toString());
		} catch (SoapFault e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"clearCart ; " + e.getMessage());
		} catch (IOException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"clearCart ; " + e.getMessage());
		} catch (XmlPullParserException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"clearCart ; " + e.getMessage());
		}
		return false;
	}

	/**
	 * 删除购物车中的商品
	 * 
	 * @param userId
	 *            用户登录后生成的Id
	 * @param goodsId
	 *            商品的Id
	 * @param userToken
	 *            用户登录后生成的Token
	 * @return boolean true 删除成功，false删除失败
	 */
	public static boolean deleteGoodsFromCart(int userId, int goodsId,
			java.lang.String userToken) {
		SoapObject request = new SoapObject(WEB_SEVICE_NAMESPACE,
				"deleteGoodsFromCart");
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(
				WEB_SERVICE_URL);
		request.addProperty("userId", userId);
		request.addProperty("goodsId", goodsId);
		request.addProperty("userToken", userToken);
		// request.setProperty(0, loginObject);
		envelope.setOutputSoapObject(request);
		try {
			androidHttpTransport.call("deleteGoodsFromCart", envelope);
			Object object = envelope.getResponse();
			return Boolean.parseBoolean(object.toString());
		} catch (SoapFault e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"deleteGoodsFromCart ; " + e.getMessage());
		} catch (IOException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"deleteGoodsFromCart ; " + e.getMessage());
		} catch (XmlPullParserException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"deleteGoodsFromCart ; " + e.getMessage());
		}
		return false;
	}

	/**
	 * 更新购物车中的商品数量
	 * 
	 * @param userId
	 *            用户登录后生成的Id
	 * @param goodsId
	 *            商品的Id
	 * @param number
	 *            商品的数量
	 * @param userToken
	 *            用户登录后生成的Token
	 * @return boolean true 更新成功，false 更新失败
	 */
	public static boolean updateGoodsNumber(int userId, int goodsId,
			int number, java.lang.String userToken) {
		SoapObject request = new SoapObject(WEB_SEVICE_NAMESPACE,
				"updateGoodsNumber");
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(
				WEB_SERVICE_URL);
		request.addProperty("userId", userId);
		request.addProperty("goodsId", goodsId);
		request.addProperty("number", number);
		request.addProperty("userToken", userToken);
		// request.setProperty(0, loginObject);
		envelope.setOutputSoapObject(request);
		try {
			androidHttpTransport.call("updateGoodsNumber", envelope);
			Object object = envelope.getResponse();
			return Boolean.parseBoolean(object.toString());
		} catch (SoapFault e) {
			LogUtil.e(WebServiceClient.class.getName(), "updateGoodsNumber ; "
					+ e.getMessage());
		} catch (IOException e) {
			LogUtil.e(WebServiceClient.class.getName(), "updateGoodsNumber ; "
					+ e.getMessage());
		} catch (XmlPullParserException e) {
			LogUtil.e(WebServiceClient.class.getName(), "updateGoodsNumber ; "
					+ e.getMessage());
		}
		return false;
	}

	/**
	 * 
	 * 添加商品到购物车,如果商品已经存在与购物车中，则会累加商品的数量
	 * 
	 * @param userId
	 *            用户登录后生成的Id
	 * @param goodsId
	 *            商品的Id
	 * @param number
	 *            商品的数量
	 * @param goodsAttr
	 *            商品尺码信息
	 * @param userToken
	 *            用户登录后生成的Token
	 * @return boolean true 添加成功，false 添加失败
	 */
	public static boolean addGoodsToCart(int userId, int goodsId, int number,
			java.lang.String goodsAttr, java.lang.String userToken) {
		SoapObject request = new SoapObject(WEB_SEVICE_NAMESPACE,
				"addGoodsToCart");
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(
				WEB_SERVICE_URL);
		request.addProperty("userId", userId);
		request.addProperty("goodsId", goodsId);
		request.addProperty("number", number);
		request.addProperty("goodsAttr", goodsAttr);
		request.addProperty("userToken", userToken);
		// request.setProperty(0, loginObject);
		envelope.setOutputSoapObject(request);
		try {
			androidHttpTransport.call("addGoodsToCart", envelope);
			Object object = envelope.getResponse();
			return Boolean.parseBoolean(object.toString());
		} catch (SoapFault e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"addGoodsToCart ; " + e.getMessage());
		} catch (IOException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"addGoodsToCart ; " + e.getMessage());
		} catch (XmlPullParserException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"addGoodsToCart ; " + e.getMessage());
		}
		return false;
	}

	/**
	 * 获取一个OrderId
	 * 
	 * @return SN
	 */
	public static String getNewOrderSn() {
		String sn = null;
		SoapObject request = new SoapObject(WEB_SEVICE_NAMESPACE,
				"getNewOrderSn");
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(
				WEB_SERVICE_URL);
		request.addProperty("phoneType", 1);
		// phoneType - 0.iphone 1.android 2.ipad
		envelope.setOutputSoapObject(request);
		try {
			androidHttpTransport.call(null, envelope);
			Object object = envelope.getResponse();
			sn = object.toString();
		} catch (SoapFault e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getNewOrderSn ; " + e.getMessage());
		} catch (IOException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getNewOrderSn ; " + e.getMessage());
		} catch (XmlPullParserException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getNewOrderSn ; " + e.getMessage());
		}
		return sn;
	}

	/**
	 * 增加商品评价
	 * 
	 * @param comment
	 *            商品评价内容
	 * @param userToken
	 *            用户登录后生成的Token
	 * @return boolean true 增加成功，false 增加失败
	 */
	public static boolean addComments(Comment comment, String userToken) {
		boolean result = false;
		SoapObject request = new SoapObject(WEB_SEVICE_NAMESPACE, "addComments");
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(
				WEB_SERVICE_URL);
		request.addProperty("commentsObjStr", comment.toJsonString());
		request.addProperty("userToken", userToken);
		envelope.setOutputSoapObject(request);
		try {
			androidHttpTransport.call(null, envelope);
			Object object = envelope.getResponse();
			result = Boolean.parseBoolean(object.toString());
		} catch (SoapFault e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"addComments ; " + e.getMessage());
		} catch (IOException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"addComments ; " + e.getMessage());
		} catch (XmlPullParserException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"addComments ; " + e.getMessage());
		}
		return result;
	}

	/**
	 * 增加用户反馈
	 * 
	 * @param comment
	 *            商品评价内容
	 * @param userToken
	 *            用户登录后生成的Token
	 * @return boolean true 增加成功，false 增加失败
	 */
	public static boolean addFeedback(Feedback comment, String userToken) {
		boolean result = false;
		SoapObject request = new SoapObject(WEB_SEVICE_NAMESPACE, "addFeedback");
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(
				WEB_SERVICE_URL);
		request.addProperty("FeedbackObjStr", comment.toJsonString());
		request.addProperty("userToken", userToken);
		envelope.setOutputSoapObject(request);
		try {
			androidHttpTransport.call(null, envelope);
			Object object = envelope.getResponse();
			result = Boolean.parseBoolean(object.toString());
		} catch (SoapFault e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"addFeedback ; " + e.getMessage());
		} catch (IOException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"addFeedback ; " + e.getMessage());
		} catch (XmlPullParserException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"addFeedback ; " + e.getMessage());
		}
		return result;
	}

	/**
	 * 获取商品评价列表总页数
	 * 
	 * @param goodsId
	 *            商品Id
	 * @return 数量
	 */
	public static Long getCommentsPageCount(int goodsId) {
		SoapObject request = new SoapObject(WEB_SEVICE_NAMESPACE,
				"getCommentsPageCount");
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(
				WEB_SERVICE_URL);
		request.addProperty("goodsId", goodsId);
		// request.setProperty(0, loginObject);
		envelope.setOutputSoapObject(request);
		try {
			androidHttpTransport.call(null, envelope);
			Object object = envelope.getResponse();
			return Long.parseLong(object.toString());
		} catch (SoapFault e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getCommentsPageCount ; " + e.getMessage());
		} catch (IOException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getCommentsPageCount ; " + e.getMessage());
		} catch (XmlPullParserException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getCommentsPageCount ; " + e.getMessage());
		}
		return 0L;
	}

	/**
	 * 获取商品评价列表
	 * 
	 * @param goodsId
	 *            商品Id
	 * @return List<Comment>
	 */
	public static ArrayList<Comment> getComments(int goodsId, int pageNum) {
		ArrayList<Comment> list = new ArrayList<Comment>();
		SoapObject request = new SoapObject(WEB_SEVICE_NAMESPACE, "getComments");
		request.addProperty("goodsId", goodsId);
		request.addProperty("pageNum", pageNum);
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(
				WEB_SERVICE_URL);
		envelope.setOutputSoapObject(request);
		try {
			androidHttpTransport.call(null, envelope);
			Object object = envelope.getResponse();
			JSONArray arr = new JSONArray(object.toString());
			int size = arr.length();
			// 当parentsId 不等于0并且等于上一条评论的commentId时，突出显示效果
			int preCommentId = 0;
			for (int i = 0; i < size; i++) {
				Comment comment = new Comment();
				comment.jsonAnalytic(arr.getJSONObject(i));
				if (comment.getParentId() != 0
						&& comment.getParentId() == preCommentId) {
					comment.setReply(true);
				} else {
					preCommentId = comment.getCommentId();
				}
				list.add(comment);
			}
		} catch (SoapFault e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getComments ; " + e.getMessage());
		} catch (IOException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getComments ; " + e.getMessage());
		} catch (XmlPullParserException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getComments ; " + e.getMessage());
		} catch (JSONException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getComments ; " + e.getMessage());
		}
		return list;
	}

	/**
	 * 获取新货信息
	 * 
	 * @param count
	 *            获取的新货数量
	 * @return ArrayList<GoodsInfo>
	 */
	public static ArrayList<GoodsInfo> getNew(int count) {
		ArrayList<GoodsInfo> list = new ArrayList<GoodsInfo>();
		SoapObject request = new SoapObject(WEB_SEVICE_NAMESPACE, "getNew");
		request.addProperty("count", count);
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(
				WEB_SERVICE_URL);
		envelope.setOutputSoapObject(request);
		try {
			androidHttpTransport.call(null, envelope);
			Object object = envelope.getResponse();
			JSONArray arr = new JSONArray(object.toString());
			int size = arr.length();
			for (int i = 0; i < size; i++) {
				GoodsInfo oodsInfo = new GoodsInfo();
				oodsInfo.jsonAnalytic(arr.getJSONObject(i));
				list.add(oodsInfo);
			}
		} catch (SoapFault e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getNew ; " + e.getMessage());
		} catch (IOException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getNew ; " + e.getMessage());
		} catch (XmlPullParserException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getNew ; " + e.getMessage());
		} catch (JSONException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getNew ; " + e.getMessage());
		}
		return list;
	}

	/**
	 * 获取相册信息
	 * 
	 * @param goodsId
	 *            商品id
	 * @return
	 */
	public static GoodsGallery getGallery(int goodsId) {
		GoodsGallery gallery = null;
		SoapObject request = new SoapObject(WEB_SEVICE_NAMESPACE, "getGallery");
		request.addProperty("goodsId", goodsId);
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(
				WEB_SERVICE_URL);
		envelope.setOutputSoapObject(request);
		try {
			androidHttpTransport.call(null, envelope);
			Object object = envelope.getResponse();
			gallery = new GoodsGallery();
			gallery.jsonAnalytic(object.toString());
		} catch (SoapFault e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getGallery ; " + e.getMessage());
		} catch (IOException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getGallery ; " + e.getMessage());
		} catch (XmlPullParserException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getGallery ; " + e.getMessage());
		}
		return gallery;
	}

	/**
	 * 搜索获取产品信息列表的总页数
	 * 
	 * @param condition
	 *            条件，产品编号或者产品名称
	 * @return 页数
	 */
	public static Long getGoodsListByQueryPageCount(java.lang.String condition) {
		SoapObject request = new SoapObject(WEB_SEVICE_NAMESPACE,
				"getGoodsListByQueryPageCount");
		if (condition.indexOf("'") != -1) {
			condition = condition.replaceAll("'", "''");
		}
		// if(condition.indexOf("&") != -1){
		// condition = condition.replaceAll("'", "\u0026");
		// }
		request.addProperty("condition", condition);
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(
				WEB_SERVICE_URL);
		// request.setProperty(0, loginObject);
		envelope.setOutputSoapObject(request);
		try {
			androidHttpTransport.call(null, envelope);
			Object object = envelope.getResponse();
			if (object != null) {
				return Long.parseLong(object.toString());
			}
		} catch (SoapFault e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getGoodsListByQueryPageCount ; " + e.getMessage());
		} catch (IOException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getGoodsListByQueryPageCount ; " + e.getMessage());
		} catch (XmlPullParserException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getGoodsListByQueryPageCount ; " + e.getMessage());
		}
		return 0L;
	}

	/**
	 * 搜索获取产品信息列表
	 * 
	 * @param condition
	 *            条件，产品编号或者产品名称
	 * @param pageNum
	 *            页数
	 * @param shortBy
	 *            排序字段
	 * @param desc
	 *            升序
	 * @return ArrayList<GoodsInfo>
	 */
	public static ArrayList<GoodsInfo> getGoodsListByQuery(
			java.lang.String condition, int pageNum, java.lang.String shortBy,
			boolean desc) {
		ArrayList<GoodsInfo> list = new ArrayList<GoodsInfo>();
		SoapObject request = new SoapObject(WEB_SEVICE_NAMESPACE,
				"getGoodsListByQuery");
		if (condition.indexOf("'") != -1) {
			condition = condition.replaceAll("'", "''");
		}
		// if(condition.indexOf("&") != -1){
		// condition = condition.replaceAll("'", "\u0026");
		// }
		request.addProperty("condition", condition);
		request.addProperty("pageNum", pageNum);
		request.addProperty("shortBy", shortBy);
		request.addProperty("desc", desc);
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(
				WEB_SERVICE_URL);
		envelope.setOutputSoapObject(request);
		try {
			androidHttpTransport.call(null, envelope);
			Object object = envelope.getResponse();
			JSONArray arr = new JSONArray(object.toString());
			int size = arr.length();
			for (int i = 0; i < size; i++) {
				GoodsInfo oodsInfo = new GoodsInfo();
				oodsInfo.jsonAnalytic(arr.getJSONObject(i));
				list.add(oodsInfo);
			}
		} catch (SoapFault e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getGoodsListByQuery ; " + e.getMessage());
		} catch (IOException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getGoodsListByQuery ; " + e.getMessage());
		} catch (XmlPullParserException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getGoodsListByQuery ; " + e.getMessage());
		} catch (JSONException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getGoodsListByQuery ; " + e.getMessage());
		}
		return list;
	}

	/**
	 * 获取商品的Attribute信息
	 * 
	 * @param goodsId
	 *            商品的Id
	 * @return ArrayList<WhoGoodsAttr>
	 */
	public static ArrayList<WhoGoodsAttr> getGoodsAttributes(int goodsId) {
		ArrayList<WhoGoodsAttr> list = new ArrayList<WhoGoodsAttr>();
		SoapObject request = new SoapObject(WEB_SEVICE_NAMESPACE,
				"getGoodsAttributes");
		request.addProperty("goodsId", goodsId);
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(
				WEB_SERVICE_URL);
		envelope.setOutputSoapObject(request);
		try {
			androidHttpTransport.call(null, envelope);
			Object object = envelope.getResponse();
			JSONArray arr = new JSONArray(object.toString());
			int size = arr.length();
			for (int i = 0; i < size; i++) {
				WhoGoodsAttr whoGoodsAttr = new WhoGoodsAttr();
				whoGoodsAttr.jsonAnalytic(arr.getJSONObject(i));
				list.add(whoGoodsAttr);
			}
		} catch (SoapFault e) {
			LogUtil.e(WebServiceClient.class.getName(), "getGoodsAttributes ; "
					+ e.getMessage());
		} catch (IOException e) {
			LogUtil.e(WebServiceClient.class.getName(), "getGoodsAttributes ; "
					+ e.getMessage());
		} catch (XmlPullParserException e) {
			LogUtil.e(WebServiceClient.class.getName(), "getGoodsAttributes ; "
					+ e.getMessage());
		} catch (JSONException e) {
			LogUtil.e(WebServiceClient.class.getName(), "getGoodsAttributes ; "
					+ e.getMessage());
		}
		return list;
	}

	/**
	 * 获取商品明细信息
	 * 
	 * @param goodsId
	 *            goodsId 商品的Id
	 * @return GoodsDetail or null ;
	 */
	public static GoodsDetail getGoodsDetail(int goodsId) {
		GoodsDetail goodsDetail = null;
		SoapObject request = new SoapObject(WEB_SEVICE_NAMESPACE,
				"getGoodsDetail");
		request.addProperty("goodsId", goodsId);
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(
				WEB_SERVICE_URL);
		envelope.setOutputSoapObject(request);
		try {
			androidHttpTransport.call(null, envelope);
			Object object = envelope.getResponse();
			goodsDetail = new GoodsDetail();
			goodsDetail.jsonAnalytic(object.toString());
		} catch (SoapFault e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getGoodsDetail ; " + e.getMessage());
		} catch (IOException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getGoodsDetail ; " + e.getMessage());
		} catch (XmlPullParserException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getGoodsDetail ; " + e.getMessage());
		}
		return goodsDetail;
	}

	/**
	 * 获取商品明细信息,用户关联的
	 * 
	 * @param goodsId
	 * @param userId
	 * @param userToken
	 * @return
	 */
	public static GoodsDetail getGoodsDetail(int goodsId, int userId,
			String userToken) {
		GoodsDetail goodsDetail = null;
		SoapObject request = new SoapObject(WEB_SEVICE_NAMESPACE,
				"getGoodsDetailByUserId");
		request.addProperty("goodsId", goodsId);
		request.addProperty("userId", userId);
		request.addProperty("userToken", userToken);
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(
				WEB_SERVICE_URL);
		envelope.setOutputSoapObject(request);
		try {
			androidHttpTransport.call(null, envelope);
			Object object = envelope.getResponse();
			goodsDetail = new GoodsDetail();
			goodsDetail.jsonAnalytic(object.toString());
		} catch (SoapFault e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getGoodsDetail ; " + e.getMessage());
		} catch (IOException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getGoodsDetail ; " + e.getMessage());
		} catch (XmlPullParserException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getGoodsDetail ; " + e.getMessage());
		}
		return goodsDetail;
	}

	/**
	 * 获取用户的商品收藏列表
	 * 
	 * @param userId
	 *            用户登录后生成的Id
	 * @param userToken
	 *            用户登录后生成的Token
	 * @return ArrayList<CollectGoods>
	 */
	public static ArrayList<CollectGoods> getMyCollectGoods(int userId,
			java.lang.String userToken) {
		ArrayList<CollectGoods> list = new ArrayList<CollectGoods>();
		SoapObject request = new SoapObject(WEB_SEVICE_NAMESPACE,
				"getMyCollectGoods");
		request.addProperty("userId", userId);
		request.addProperty("userToken", userToken);
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(
				WEB_SERVICE_URL);
		envelope.setOutputSoapObject(request);
		try {
			androidHttpTransport.call(null, envelope);
			Object object = envelope.getResponse();
			JSONArray arr = new JSONArray(object.toString());
			int size = arr.length();
			for (int i = 0; i < size; i++) {
				CollectGoods collectGoods = new CollectGoods();
				collectGoods.jsonAnalytic(arr.getJSONObject(i));
				list.add(collectGoods);
			}
		} catch (SoapFault e) {
			LogUtil.e(WebServiceClient.class.getName(), "getMyCollectGoods ; "
					+ e.getMessage());
		} catch (IOException e) {
			LogUtil.e(WebServiceClient.class.getName(), "getMyCollectGoods ; "
					+ e.getMessage());
		} catch (XmlPullParserException e) {
			LogUtil.e(WebServiceClient.class.getName(), "getMyCollectGoods ; "
					+ e.getMessage());
		} catch (JSONException e) {
			LogUtil.e(WebServiceClient.class.getName(), "getMyCollectGoods ; "
					+ e.getMessage());
		}
		return list;
	}

	/**
	 * 商品收藏操作
	 * 
	 * @param collectGoods
	 *            CollectGoods 对象
	 * @param opType
	 *            操作类型 0.新增 1.修改 2.删除
	 * @param userToken
	 * @return true or false or null
	 */
	public static Boolean operateCollectGoods(CollectGoods collectGoods,
			int opType, java.lang.String userToken) {
		Boolean result = false;
		SoapObject request = new SoapObject(WEB_SEVICE_NAMESPACE,
				"operateCollectGoods");
		request.addProperty("gollectGoodsObjStr",
				collectGoods.toJsonString(opType));
		request.addProperty("opType", opType);
		request.addProperty("userToken", userToken);
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(
				WEB_SERVICE_URL);
		envelope.setOutputSoapObject(request);
		try {
			androidHttpTransport.call(null, envelope);
			Object object = envelope.getResponse();
			if (object != null
					&& (object.toString().equals("0") || object.toString()
							.equals("true"))) {
				result = true;
			} else {
				result = false;
			}
		} catch (SoapFault e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"operateCollectGoods ; " + e.getMessage());
		} catch (IOException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"operateCollectGoods ; " + e.getMessage());
		} catch (XmlPullParserException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"operateCollectGoods ; " + e.getMessage());
		}
		return result;
	}

	// /**
	// * paypal支付成功后，在who_order_info表的pay_note字段中设置paypal的交易号
	// *
	// * @param orderId
	// * 要设置的订单id
	// * @param paypalId
	// * paypal的交易号
	// * @param userId
	// * @param userToken
	// * @return Boolean 是否设置成功
	// */
	// public static Boolean setPaypalId(int orderId, java.lang.String paypalId,
	// int userId, java.lang.String userToken) {
	// Boolean result = false;
	// SoapObject request = new SoapObject(WEB_SEVICE_NAMESPACE, "setPaypalId");
	// request.addProperty("orderId", orderId);
	// request.addProperty("paypalId", paypalId);
	// request.addProperty("userId", userId);
	// request.addProperty("userToken", userToken);
	// SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
	// SoapEnvelope.VER11);
	// HttpTransportSE androidHttpTransport = new HttpTransportSE(
	// WEB_SERVICE_URL);
	// envelope.setOutputSoapObject(request);
	// try {
	// androidHttpTransport.call(null, envelope);
	// Object object = envelope.getResponse();
	// if (object != null) {
	// result = Boolean.parseBoolean(object.toString());
	// }
	// } catch (SoapFault e) {
	// LogUtil.e(WebServiceClient.class.getName(),
	// "setPaypalId ; " + e.getMessage());
	// } catch (IOException e) {
	// LogUtil.e(WebServiceClient.class.getName(),
	// "setPaypalId ; " + e.getMessage());
	// } catch (XmlPullParserException e) {
	// LogUtil.e(WebServiceClient.class.getName(),
	// "setPaypalId ; " + e.getMessage());
	// }
	// return result;
	// }

	/**
	 * 获取用户order信息列表
	 * 
	 * @param userId
	 * @param inTwoMonth
	 *            是否是获取两个月内的数据
	 * @param userToken
	 * @return ArrayList<Order>
	 */
	public static ArrayList<Order> getMyOrders(int userId, boolean inTwoMonth,
			java.lang.String userToken) {
		ArrayList<Order> list = new ArrayList<Order>();
		SoapObject request = new SoapObject(WEB_SEVICE_NAMESPACE, "getMyOrders");
		request.addProperty("userId", userId);
		request.addProperty("inTwoMonth", inTwoMonth);
		request.addProperty("userToken", userToken);
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(
				WEB_SERVICE_URL);
		envelope.setOutputSoapObject(request);
		try {
			androidHttpTransport.call(null, envelope);
			Object object = envelope.getResponse();
			JSONArray arr = new JSONArray(object.toString());
			int size = arr.length();
			for (int i = 0; i < size; i++) {
				Order order = new Order();
				order.jsonAnalytic(arr.getJSONObject(i));
				list.add(order);
			}
		} catch (SoapFault e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getMyOrders ; " + e.getMessage());
		} catch (IOException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getMyOrders ; " + e.getMessage());
		} catch (XmlPullParserException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getMyOrders ; " + e.getMessage());
		} catch (JSONException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getMyOrders ; " + e.getMessage());
		}
		return list;
	}

	/**
	 * 获取该用户所有的收货地址列表
	 * 
	 * @param userId
	 * @param userToken
	 * @return ArrayList<UserAddress>
	 */
	public static ArrayList<UserAddress> getUserAddress(int userId,
			java.lang.String userToken) {
		ArrayList<UserAddress> list = new ArrayList<UserAddress>();
		SoapObject request = new SoapObject(WEB_SEVICE_NAMESPACE,
				"getUserAddress");
		request.addProperty("userId", userId);
		request.addProperty("userToken", userToken);
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(
				WEB_SERVICE_URL);
		envelope.setOutputSoapObject(request);
		try {
			androidHttpTransport.call(null, envelope);
			Object object = envelope.getResponse();
			JSONArray arr = new JSONArray(object.toString());
			int size = arr.length();
			for (int i = 0; i < size; i++) {
				UserAddress userAddress = new UserAddress();
				userAddress.jsonAnalytic(arr.getJSONObject(i));
				list.add(userAddress);
			}
		} catch (SoapFault e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getUserAddress ; " + e.getMessage());
		} catch (IOException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getUserAddress ; " + e.getMessage());
		} catch (XmlPullParserException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getUserAddress ; " + e.getMessage());
		} catch (JSONException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getUserAddress ; " + e.getMessage());
		}
		return list;
	}

	/**
	 * 获取该用户当前的收货地址，与user表中的address_id对应的地址
	 * 
	 * @param userId
	 * @param userToken
	 * @return ArrayList<UserAddress>
	 */
	public static UserAddress getCurrentUserAddress(int userId,
			java.lang.String userToken) {
		UserAddress userAddress = null;
		SoapObject request = new SoapObject(WEB_SEVICE_NAMESPACE,
				"getCurrentUserAddress");
		request.addProperty("userId", userId);
		request.addProperty("userToken", userToken);
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(
				WEB_SERVICE_URL);
		envelope.setOutputSoapObject(request);
		try {
			androidHttpTransport.call(null, envelope);
			Object object = envelope.getResponse();
			userAddress = new UserAddress();
			userAddress.jsonAnalytic(object.toString());
		} catch (SoapFault e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getCurrentUserAddress ; " + e.getMessage());
		} catch (IOException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getCurrentUserAddress ; " + e.getMessage());
		} catch (XmlPullParserException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getCurrentUserAddress ; " + e.getMessage());
		}
		return userAddress;
	}

	/**
	 * 设置该用户当前的收货地址，与user表中的address_id对应的地址
	 * 
	 * @param userId
	 * @param addressId
	 * @param userToken
	 * @return
	 */
	public static Boolean setCurrentUserAddress(int userId, int addressId,
			java.lang.String userToken) {
		Boolean result = false;
		SoapObject request = new SoapObject(WEB_SEVICE_NAMESPACE,
				"setCurrentUserAddress");
		request.addProperty("userId", userId);
		request.addProperty("addressId", addressId);
		request.addProperty("userToken", userToken);
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(
				WEB_SERVICE_URL);
		envelope.setOutputSoapObject(request);
		try {
			androidHttpTransport.call(null, envelope);
			Object object = envelope.getResponse();
			if (object != null) {
				result = Boolean.parseBoolean(object.toString());
			}
		} catch (SoapFault e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"setCurrentUserAddress ; " + e.getMessage());
		} catch (IOException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"setCurrentUserAddress ; " + e.getMessage());
		} catch (XmlPullParserException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"setCurrentUserAddress ; " + e.getMessage());
		}
		return result;
	}

	/**
	 * 操作用户收货地址
	 * 
	 * @param userAddress
	 *            UserAddress对象
	 * @param opType
	 *            操作类型 0.新增 1.修改 2.删除
	 * @param userToken
	 * @return true or false
	 */
	public static Boolean operateUserAddress(UserAddress userAddress,
			int opType, java.lang.String userToken) {
		Boolean result = false;
		SoapObject request = new SoapObject(WEB_SEVICE_NAMESPACE,
				"operateUserAddress");
		if (opType == 2) {
			request.addProperty("userAddressObjStr",
					userAddress.toJsonStringForDelete());
		} else {
			request.addProperty("userAddressObjStr", userAddress.toJsonString());
		}
		request.addProperty("opType", opType);
		request.addProperty("userToken", userToken);
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(
				WEB_SERVICE_URL);
		envelope.setOutputSoapObject(request);
		try {
			androidHttpTransport.call(null, envelope);
			Object object = envelope.getResponse();
			if (object != null) {
				result = Boolean.parseBoolean(object.toString());
			}
		} catch (SoapFault e) {
			LogUtil.e(WebServiceClient.class.getName(), "operateUserAddress ; "
					+ e.getMessage());
		} catch (IOException e) {
			LogUtil.e(WebServiceClient.class.getName(), "operateUserAddress ; "
					+ e.getMessage());
		} catch (XmlPullParserException e) {
			LogUtil.e(WebServiceClient.class.getName(), "operateUserAddress ; "
					+ e.getMessage());
		}
		return result;
	}

	/**
	 * 获取用户的所有订单追踪信息
	 * 
	 * @param userId
	 * @param userToken
	 * @return ArrayList<OrderTrackingInfo>
	 */
	public static ArrayList<OrderTrackingInfo> getMyOrderTrackings(int userId,
			java.lang.String userToken) {
		ArrayList<OrderTrackingInfo> list = new ArrayList<OrderTrackingInfo>();
		SoapObject request = new SoapObject(WEB_SEVICE_NAMESPACE,
				"getMyOrderTrackings");
		request.addProperty("userId", userId);
		request.addProperty("userToken", userToken);
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(
				WEB_SERVICE_URL);
		envelope.setOutputSoapObject(request);
		try {
			androidHttpTransport.call(null, envelope);
			Object object = envelope.getResponse();
			JSONArray arr = new JSONArray(object.toString());
			int size = arr.length();
			for (int i = 0; i < size; i++) {
				OrderTrackingInfo orderTrackingInfo = new OrderTrackingInfo();
				orderTrackingInfo.jsonAnalytic(arr.getJSONObject(i));
				list.add(orderTrackingInfo);
			}
		} catch (SoapFault e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getMyOrderTrackings ; " + e.getMessage());
		} catch (IOException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getMyOrderTrackings ; " + e.getMessage());
		} catch (XmlPullParserException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getMyOrderTrackings ; " + e.getMessage());
		} catch (JSONException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getMyOrderTrackings ; " + e.getMessage());
		}
		return list;
	}

	public static String getShippingTrackingUrl(
			OrderTrackingInfo orderTrackingInfo) {
		String result = null;
		SoapObject request = new SoapObject(WEB_SEVICE_NAMESPACE,
				"getShippingTrackingUrl");
		request.addProperty("shippingId", orderTrackingInfo.getShippingId());
		request.addProperty("invoiceNo", orderTrackingInfo.getInvoiceNo());
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(
				WEB_SERVICE_URL);
		envelope.setOutputSoapObject(request);
		try {
			androidHttpTransport.call(null, envelope);
			Object object = envelope.getResponse();
			result = object.toString();
		} catch (SoapFault e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getShippingTrackingUrl ; " + e.getMessage());
		} catch (IOException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getShippingTrackingUrl ; " + e.getMessage());
		} catch (XmlPullParserException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getShippingTrackingUrl ; " + e.getMessage());
		}
		return result;
	}

	/**
	 * 上传订单操作
	 * 
	 * @param orderObjStr
	 * @param opType
	 *            操作类型，0.新增 1.修改 2.删除 如果是删除，实体中只需要order的id即可
	 * @param userToken
	 * @return UploadOrderResponse
	 */
	public static UploadOrderResponse uploadOrder(Order order, int opType,
			java.lang.String userToken) {
		UploadOrderResponse result = null;
		SoapObject request = new SoapObject(WEB_SEVICE_NAMESPACE, "uploadOrder");
		request.addProperty("orderObjStr", order.toJsonString(opType));
		request.addProperty("opType", opType);
		request.addProperty("userToken", userToken);
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(
				WEB_SERVICE_URL);
		envelope.setOutputSoapObject(request);
		try {
			androidHttpTransport.call(null, envelope);
			Object object = envelope.getResponse();
			result = new UploadOrderResponse();
			result.jsonAnalytic(object.toString());
		} catch (SoapFault e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"uploadOrder ; " + e.getMessage());
		} catch (IOException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"uploadOrder ; " + e.getMessage());
		} catch (XmlPullParserException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"uploadOrder ; " + e.getMessage());
		}
		return result;
	}

	/**
	 * 获取more列表
	 * 
	 * @return
	 */
	public static List<HashMap<String, Object>> getMoreData() {
		List<HashMap<String, Object>> listItem = new ArrayList<HashMap<String, Object>>();
		HashMap<String, Object> accountMap = new HashMap<String, Object>();
		accountMap.put("text", "My Account");
		listItem.add(accountMap);
		HashMap<String, Object> searchMap = new HashMap<String, Object>();
		searchMap.put("text", "Search");
		listItem.add(searchMap);
		HashMap<String, Object> histroryMap = new HashMap<String, Object>();
		histroryMap.put("text", "History");
		listItem.add(histroryMap);
		HashMap<String, Object> helpMap = new HashMap<String, Object>();
		helpMap.put("text", "Help");
		listItem.add(helpMap);
		HashMap<String, Object> feedBackMap = new HashMap<String, Object>();
		feedBackMap.put("text", "Feed back");
		listItem.add(feedBackMap);
		HashMap<String, Object> aboutMap = new HashMap<String, Object>();
		aboutMap.put("text", "About");
		listItem.add(aboutMap);
		return listItem;
	}

	/**
	 * 
	 * 获取账号功能列表
	 * 
	 * @return
	 */
	public static List<HashMap<String, Object>> getMyAccountData() {
		List<HashMap<String, Object>> listItem = new ArrayList<HashMap<String, Object>>();
		HashMap<String, Object> ordersMap = new HashMap<String, Object>();
		ordersMap.put("text", "My orders");
		listItem.add(ordersMap);
		HashMap<String, Object> packagesMap = new HashMap<String, Object>();
		packagesMap.put("text", "Tracking packages");
		listItem.add(packagesMap);
		HashMap<String, Object> addressMap = new HashMap<String, Object>();
		addressMap.put("text", "My address");
		listItem.add(addressMap);
		HashMap<String, Object> favoritesMap = new HashMap<String, Object>();
		favoritesMap.put("text", "My favorites");
		listItem.add(favoritesMap);
		HashMap<String, Object> commentsMap = new HashMap<String, Object>();
		commentsMap.put("text", "My comments");
		listItem.add(commentsMap);
		HashMap<String, Object> feedbackMap = new HashMap<String, Object>();
		feedbackMap.put("text", "My feed back");
		listItem.add(feedbackMap);
		return listItem;
	}

	/**
	 * 获取WhoAttribute表中的数据
	 * 
	 * @return ArrayList<WhoAttribute>
	 */
	public static ArrayList<WhoAttribute> getAttributes() {
		ArrayList<WhoAttribute> list = new ArrayList<WhoAttribute>();
		SoapObject request = new SoapObject(WEB_SEVICE_NAMESPACE,
				"getAttributes");
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(
				WEB_SERVICE_URL);
		envelope.setOutputSoapObject(request);
		try {
			androidHttpTransport.call("getAttributes", envelope);
			Object object = envelope.getResponse();
			JSONArray arr = new JSONArray(object.toString());
			int size = arr.length();
			for (int i = 0; i < size; i++) {
				WhoAttribute who = new WhoAttribute();
				who.jsonAnalytic(arr.getJSONObject(i));
				list.add(who);
			}
		} catch (SoapFault e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getAttributes ; " + e.getMessage());
		} catch (IOException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getAttributes ; " + e.getMessage());
		} catch (XmlPullParserException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getAttributes ; " + e.getMessage());
		} catch (JSONException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"getAttributes ; " + e.getMessage());
		}
		return list;
	}

	public static boolean setPaypalId(String orderSn, String paypalId,
			int userId, String userToken) {
		boolean result = false;
		SoapObject request = new SoapObject(WEB_SEVICE_NAMESPACE, "setPaypalId");
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(
				WEB_SERVICE_URL);
		request.addProperty("orderSn", orderSn);
		request.addProperty("paypalId", paypalId);
		request.addProperty("userId", userId);
		request.addProperty("userToken", userToken);
		envelope.setOutputSoapObject(request);
		try {
			androidHttpTransport.call(null, envelope);
			Object object = envelope.getResponse();
			result = Boolean.parseBoolean(object.toString());
		} catch (SoapFault e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"setPaypalId ; " + e.getMessage());
		} catch (IOException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"setPaypalId ; " + e.getMessage());
		} catch (XmlPullParserException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"setPaypalId ; " + e.getMessage());
		}
		return result;
	}

	public static void getImagePreUrl() {
		String result = null;
		SoapObject request = new SoapObject(WEB_SEVICE_NAMESPACE,
				"getImagePreUrl");
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(
				WEB_SERVICE_URL);
		envelope.setOutputSoapObject(request);
		try {
			androidHttpTransport.call(null, envelope);
			Object object = envelope.getResponse();
			result = object.toString();
		} catch (SoapFault e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"setPaypalId ; " + e.getMessage());
		} catch (IOException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"setPaypalId ; " + e.getMessage());
		} catch (XmlPullParserException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"setPaypalId ; " + e.getMessage());
		}
		if (result != null) {
			Constants.IMAGE_URL = result;
		}
	}

	public static void getSystemParams() {
		String result = null;
		SoapObject request = new SoapObject(WEB_SEVICE_NAMESPACE,
				"getSystemParams");
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(
				WEB_SERVICE_URL);
		envelope.setOutputSoapObject(request);
		try {
			androidHttpTransport.call(null, envelope);
			Object object = envelope.getResponse();
			result = object.toString();
		} catch (SoapFault e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"setPaypalId ; " + e.getMessage());
		} catch (IOException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"setPaypalId ; " + e.getMessage());
		} catch (XmlPullParserException e) {
			LogUtil.e(WebServiceClient.class.getName(),
					"setPaypalId ; " + e.getMessage());
		}
		if (result != null) {
			try {
				JSONArray arr = new JSONArray(result);
				List<String> params = new ArrayList<String>();
				for (int i = 0; i < arr.length(); i++) {
					params.add(arr.getString(i));
				}
				for (String str : params) {
					String[] keyValue = str.split(":");
					Constants.sysPrarms.put(keyValue[0], keyValue[1]);
					Constants.menFormalId = Integer.parseInt(keyValue[1]);
				}
			} catch (JSONException e) {
				e.printStackTrace();
			}
		}
	}

	/**
	 * 搜索获取产品信息列表
	 * 
	 * @param condition
	 *            条件，产品编号或者产品名称
	 * @param pageNum
	 *            页数
	 * @param shortBy
	 *            排序字段
	 * @param desc
	 *            升序
	 * @return ArrayList<GoodsInfo>
	 */
	public static ArrayList<GoodsInfo> getGoodsListByIds(String ids) {
		ArrayList<GoodsInfo> list = new ArrayList<GoodsInfo>();
		SoapObject request = new SoapObject(WEB_SEVICE_NAMESPACE,
				"getGoodsListByIds");
		request.addProperty("ids", ids);
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(
				WEB_SERVICE_URL);
		envelope.setOutputSoapObject(request);
		try {
			androidHttpTransport.call(null, envelope);
			Object object = envelope.getResponse();
			JSONArray arr = new JSONArray(object.toString());
			int size = arr.length();
			for (int i = 0; i < size; i++) {
				GoodsInfo oodsInfo = new GoodsInfo();
				oodsInfo.jsonAnalytic(arr.getJSONObject(i));
				list.add(oodsInfo);
			}
		} catch (SoapFault e) {
			LogUtil.e(WebServiceClient.class.getName(), "getGoodsListByIds ; "
					+ e.getMessage());
		} catch (IOException e) {
			LogUtil.e(WebServiceClient.class.getName(), "getGoodsListByIds ; "
					+ e.getMessage());
		} catch (XmlPullParserException e) {
			LogUtil.e(WebServiceClient.class.getName(), "getGoodsListByIds ; "
					+ e.getMessage());
		} catch (JSONException e) {
			LogUtil.e(WebServiceClient.class.getName(), "getGoodsListByIds ; "
					+ e.getMessage());
		}
		return list;
	}
}
